Getting Started

If you’re reading this tutorial, you’ve probably built up your first Stack with us and are looking to connect to it. With cloud computing, you’re able to perform actions on a computer you might not have physical access to. Although you might interact with your local machine using the beautiful GUI packaged with your operating system, you must interact with your remote machine primarily using the shell and the command line. If you’ve never used the command line before and do not know what the shell is, we suggest you check out this link for a small primer on the shell and terminal.

Lets Get to It

We will be using Secure Shell, otherwise known has SSH, to log into our remote machine and begin executing commands. First, get the IP address of the remote machine (stack) that you wish to connect to. If you’ve never connected to this machine before, you will have to log on as the ‘root’ user and configure your machine appropriately. Execute the following command on your local machine:

ssh root@YOUR_REMOTE_MACHINE_IP_ADDRESS

Replacing the capitalized placeholder with your Stack’s public IP address.

You’ll be prompted for the root password of the machine

root@YOUR_REMOTE_MACHINE_IP_ADDRESS's password:

Type in the password you created when building your stack and you’ll gain command line access to your remote machine:

root@hostname:~#

Where ‘hostname’ is the name you gave to the stack when creating it on the dashboard. Now you’re ready to create users, install packages, and begin developing using your pre-built or customized Stack.

Create Non-Root Sudo User

For security reasons, you’ll want to create a non-root user with superuser privileges so that you’re not running every single command using the root user. This way, you mitigate the possibility of accidentally running a catastrophic command with no security check before it. We’ll use the adduser command to do so.

adduser myNonrootUser

You can change ‘myNonrootUser’ to whatever you like. You will be prompted to enter a password for this user in addition to some auxiliary information related to the account user. You can add these if you wish, but it is not necessary. Now that we’ve added the new account, we have to add it to the ‘sudoers’ group so that it is allowed to run commands as sudo. Run the following command (as the root user):

adduser myNonRootUser sudo

That’s it — we should be all set up to log in using this non-root account and run commands as ‘sudo’. Logout from your SSH session using the exit command and SSH into your machine again using the new user you’ve created. The command should look as follows:

ssh myNonrootUser@YOUR_REMOTE_MACHINE_IP_ADDRESS

You will have to replace the placeholder appropriately and enter your password. Once you’re successfully connected, your shell prompt should reflect the new user that you’re logged in as. To test whether you can run commands as sudo, run a simple sudo apt-get update if you’re using a Ubuntu/Debian Stack or sudo yum update if you’re running a CentOS stack. If everything proceeded correctly, you’ll see a lot of text being logged to the console — do not fret, this just means that your package repositories are being checked for updates (something you should do periodically).

Final Words

Congratulations! You know the basics of logging into your remote machine and creating a non-root user. You’re ready to do just about anything you can think of with your Stack. For ideas and tutorials, check out our Community Section.